home *** CD-ROM | disk | FTP | other *** search
- /* Optimized with RexxOpt 1.8 */
- ARG ACTION;NL='0a'x;PRAGMA('W','N');if ~show('l',rexxsupport.library) then;call addlib("rexxsupport.library",0,-30,0);if ~exists('libs:rexxreqtools.library') then;do;say "Error! rexxreqtools.library not found! Please run the Miami Control setup prog which will install it for you.";call cleanup;end;if ~show('l',rexxreqtools.library) then;call addlib("rexxreqtools.library",0,-30,0);if ~show('p','MIAMICONTROL.1') then;do;mcport=OPENPORT(MIAMICONTROL.1);otherport=MIAMICONTROL.2;end;else;do;mcport=OPENPORT(MIAMICONTROL.2);otherport=MIAMICONTROL.1;end;if mcport=0 then;do;call rtezrequest("Unable to create ARexx port.","Oh well...","Error!","rtez_flags = ezreqf_centertext");end;if exists('S:mccheckpoint.tmp') then;do;if otherport='MIAMICONTROL.1' then;do;if ~show('p','MIAMICONTROL.1') then;do;call rtezrequest("Checkpoint File detected! Recover?","Yes|No","Checkpoint File Detected!","rtez_flags = ezreqf_centertext");if rtresult=0 then;delete('s:mccheckpoint.tmp');else;do;recovering=1;call checkpointrecover;end;end;end;else;if ~show('p','MIAMICONTROL.2') then;do;call rtezrequest("Checkpoint File detected! Recover?","Yes|No","Checkpoint File Detected!","rtez_flags = ezreqf_centertext");if rtresult=0 then;delete('s:mccheckpoint.tmp');else;do;recovering=1;call checkpointrecover;end;end;end;else;recovering=0;if ~show('P','MIAMI.1') then;do;if ~exists("Miami:Miami") then;do;call rtezrequest("Miami executable not found!!!"||NL||"Please ensure the Miami directory is assigned to Miami:.","I will!","Fatal Error!","rtez_flags = ezreqf_centertext");call cleanup;end;address command;'run >nil: Miami:Miami';address;inc=0;do while inc<30;if ~show('p',MIAMI.1) then;call delay(25);else;leave;inc=inc+1;end;if rc=5 then;do;call rtezrequest("Miami was not running on execution"||NL||"of Miami Control. Miami Control attempted"||NL||"to start Miami, but failed.","Bum","Fatal Error!","rtez_flags = ezreqf_centertext");call cleanup;end;end;select;when ACTION='?' then;do;options prompt 'Miami Control: CONNECT/S,DISCONNECT/S:';pull ACTION;end;when ACTION='CONNECT' then;do;address MIAMI.1;ISONLINE;if rc==0 then;call connect;else;call cleanup;end;when ACTION='DISCONNECT' then;do;address MIAMI.1;ISONLINE;if rx==1 then;call disconnect;else;call cleanup;end;otherwise;do;decide:;address MIAMI.1;ISONLINE;if rc==0 then;call notconnected;else;call connected;end;call cleanup;notconnected:;call setrate;address;call rtezrequest("Are you sure you wish to connect?"||NL||"Current chargerate is "||currentrate||" p per minute.","Connect|Control|Cancel","Miami Control","rtez_flags = ezreqf_centertext");select;when rtresult==0 then;call cleanup;when rtresult==1 then;call connect;when rtresult==2 then;call control;otherwise;call cleanup;end;call cleanup;connected:;call setrate;if OPEN(minim,'Env:mincharge','r') then;do;mincharge=readln(minim);call CLOSE minim;end;else;mincharge=0;address MIAMI.1;options results;GETCONNECTTIME;connecttime=result;totalcost=((connecttime/60)+1)*currentrate;if totalcost<mincharge then;totalcost=mincharge;mintime=trunc((connecttime/60),0);sectime=connecttime//60;totalcost=trunc(totalcost,2);GETCONNECT;connectstr=result;if exists("s:connect-sequence") then;do;call rtezrequest("Are you sure you wish to disconnect?"||NL||"Connect speed: "||connectstr||"."||NL||"Call length: "||mintime||" minutes and "||sectime||" seconds."||NL||"Call cost: "||totalcost||" p.","Disconnect|Disconnect Without Script|Control|Cancel","Miami Control","rtez_flags = ezreqf_centertext");select;when rtresult==0 then;call cleanup;when rtresult==1 then;do;noscript=0;call disconnect;end;when rtresult==2 then;do;noscript=1;call disconnect;end;when rtresult==3 then;call control;otherwise;call cleanup;end;end;else;do;call rtezrequest("Are you sure you wish to disconnect?"||NL||"Connect speed: "||connectstr||"."||NL||"Call length: "||mintime||" minutes and "||sectime||" seconds."||NL||"Call cost: "||totalcost||" p.","Disconnect|Control|Cancel","Miami Control","rtez_flags = ezreqf_centertext");select;when rtresult==0 then;call cleanup;when rtresult==1 then;do;noscript=0;call disconnect;end;when rtresult==2 then;call control;otherwise;call cleanup;end;end;call cleanup;connect:;address MIAMI.1;ONLINE;incre=0;connected=0;do while connected=0;if incre<20 then;do;ISONLINE;connected=rc;call delay(25);incre=incre+1;end;else;do;call rtezrequest("After waiting for over 10 seconds, Miami still"||NL||"reports being offline."||NL||"What would you like to do?","Wait some more|Give up checking|Quit Miami","Connection Failiure!","rtez_flags = ezreqf_centertext");select;when rtresult=0 then;do;address MIAMI.1;QUIT;call cleanup;end;when rtresult=1 then;incre=0;otherwise;call cleanup;end;end;end;ISONLINE;If rc=1 then;do;if open(contimedate,'s:mcconnectiontime.tmp','w') then;do;writeln(contimedate, date(e)" <> "time());call CLOSE(contimedate);end;options results;GETCONNECT;connectstr=result;if exists("s:connect-sequence") then;do;call rtezrequest("Connected at "||connectstr||" BPS","Run Connect Script|Don't Run Connect Script","Connected!","rtez_flags = ezreqf_centertext");select;when rtresult=1 then;do;address COMMAND;'Execute s:connect-sequence';address;end;otherwise;nop;end;end;else;do;call rtezrequest("Connected at "||connectstr||" BPS","Ok","Connected!","rtez_flags = ezreqf_centertext");end;end;else;do;call rtezrequest("Connection failure!","Reattempt Connection|Give up","Connection Failure!","rtez_flags = ezreqf_centertext");if rtresult=0 then;call cleanup;else;call connect;end;call checkpoint;call cleanup;disconnect:;if noscript ~=1 then;do;if exists("s:disconnect-sequence") then;do;address COMMAND;'Execute s:disconnect-sequence';address;end;end;call setrate;if OPEN(minim,'Env:mincharge','r') then;do;mincharge=readln(minim);call CLOSE currcost;end;else;mincharge=0;address MIAMI.1;options results;GETCONNECTTIME;connecttime=(result/60);checkpointrecover:;if recovering=1 then;do;call setrate;if OPEN(minim,'Env:mincharge','r') then;do;mincharge=readln(minim);call CLOSE currcost;end;else;mincharge=0;if open(ckpoint,'S:mccheckpoint.tmp') then;do;connecttime=readln(ckpoint)/60;call close(ckpoint);delete('s:mccheckpoint.tmp');end;end;if open(contimedate,'S:mcconnectiontime.tmp','r') then;do;starttime=readln(contimedate);call CLOSE(contimedate);delete('s:mcconnectiontime.tmp');end;else;starttime="XX/XX/XX <> XX:XX:XX";totalcost=(connecttime+1)*currentrate;if totalcost<mincharge then;totalcost=mincharge;totalcost=trunc(totalcost,2);if recovering ~=1 then;OFFLINE;if open(phonelog,'S:PhoneLog.Log','A') then;do;currdate= date(e);currtime=time();parse var starttime condate" <> "contime;writeln(phonelog,condate" | "contime" | "currdate" | "currtime" | "totalcost);call close(phonelog);end;else;do;if open(phonelog,'S:PhoneLog.Log','W') then;do;writeln(phonelog," Start | Start | End | End");writeln(phonelog,"DD/MM/YY | HH:MM:SS | DD/MM/YY | HH:MM:SS | Cost");writeln(phonelog,"-------- | -------- | -------- | -------- | ----");currdate= date(e);currtime=time();parse var starttime condate" <> "contime;writeln(phonelog,condate" | "contime" | "currdate" | "currtime" | "totalcost);call close(phonelog);end;end;incre=0;if recovering ~=1 then;do while rc~=0;if incre<20 then;do;ISONLINE;call delay(25);incre=incre+1;end;else;do;call rtezrequest("After waiting for over 10 seconds, Miami still"||NL||"reports being online."||NL||"What would you like to do?","Wait some more|Give up checking|Quit Miami","Connection Failiure!","rtez_flags = ezreqf_centertext");select;when rtresult==0 then;do;address MIAMI.1;QUIT;call cleanup;end;when rtresult==1 then;incre=0;otherwise;call cleanup;end;end;end;if recovering ~=1 then;do;if otherport='MIAMICONTROL.2' then;do;address MIAMICONTROL.2;'DIE';end;else;if otherport='MIAMICONTROL.1' then;do;address MIAMICONTROL.1;'DIE';end;end;call cleanup;control:;address MIAMI.1;options results;GETSETTINGSNAME;currsettings=result;call rtezrequest("What do you want to do?"||NL||"Current settings: "||currsettings||"","Quit|Show|Hide|Kill GUI|Anylise log|Load New Settings|Back","Miami Control","rtez_flags = ezreqf_centertext rtez_defaultresponse = 0");select;when rtresult==0 then;call decide;when rtresult==1 then;do;address MIAMI.1;QUIT;end;when rtresult==2 then;do;address MIAMI.1;SHOW;end;when rtresult==3 then;do;address MIAMI.1;HIDE;end;when rtresult==4 then;do;address MIAMI.1;KILLGUI;end;when rtresult==5 then;do;call examinelog;call control;end;when rtresult==6 then;do;newsettings=rtfilerequest("Miami:",,"Choose Settings File","Select",);if rtresult==1 then;do;address MIAMI.1;LOADSETTINGS newsettings;call rtezrequest("New settings file loaded."||NL||"New settings: "||newsettings||"","Keep|Revert","New Settings File Loaded","rtez_flags = ezreqf_centertext");if rtresult==0 then;do;LOADSETTINGS currsettings;call control;end;else;call control;end;else;call control;end;otherwise;call decide;end;call cleanup;examinelog:;totalcost=0;line=0;if OPEN(lfile,'s:phonelog.log','r') then;do;do i=1 TO 3;tmp=readln(lfile);starting=0;end;do forever;if starting=1 then;do i=1 TO 3;tmp=readln(lfile);starting=0;end;tmp=readln(lfile);if tmp="" then;leave;parse VAR tmp startdate" | "starttime" | "enddate" | "endtime" | "cost;totalcost=totalcost+cost;if line=0 then;do;if startdate="XX/XX/XX" then;firstdate=enddate;else;firstdate=startdate;end;line=line+1;end;end;else;do;call rtezrequest("Unable to Open logfile!","Bum","Error!","rtez_flags = ezreqf_centertext");call control;end;call close lfile;parse var firstdate day"/"month"/"year;if year>=98 then;year=19""year;else;year=20""year;tmp=year""month""day;nodaystart= date('i',tmp,s);parse var enddate day"/"month"/"year;if year>=98 then;year=19""year;else;year=20""year;tmp=year""month""day;nodayend= date('i',tmp,s);totaldays=nodayend-nodaystart;avcost=totalcost/totaldays;avconn=line/totaldays;call rtezrequest("First logged date is: "||firstdate NL||"Last logged date is: "||enddate NL||"Total number of days: "||totaldays NL||"No of connections: "||line NL||"Connections per day: "||avconn NL||"Total cost of calls: "||totalcost||"p"||NL||"Average cost per day: "||avcost||"p","Far too high!","Logging Information","rtez_flags = ezreqf_centertext");call control;exit;setrate:;currday= date(w);select;when currday="Saturday" then;do;if OPEN(wkrate,'Env:weekendrate','r') then;do;currentrate=readln(wkrate);call close wkrate;end;else;currentrate=1;end;when currday="Sunday" then;do;say;if OPEN(wkrate,'Env:weekendrate','r') then;do;currentrate=readln(wkrate);call close wkrate;end;else;currentrate=1;end;otherwise;do;if OPEN(peakratetimes,'Env:peakratetimes','r') then;do;prt=readln(peakratetimes);call CLOSE peakratetimes;end;else;prt=0818;prstart=left(prt,2);prfin=right(prt,2);currhour=time(h);if currhour>=prstart then;do;if currhour<prfin then;do;if OPEN(perate,'Env:peakrate','r') then;do;currentrate=readln(perate);call close perate;end;else;currentrate=3.95;end;else;do;if OPEN(evrate,'Env:eveningrate','r') then;do;currentrate=readln(evrate);call close evrate;end;else;currentrate=1.5;end;end;else;do;if OPEN(evrate,'Env:eveningrate','r') then;do;currentrate=readln(evrate);call close evrate;end;else;currentrate=1.5;end;end;end;return currentrate;checkpoint:;retry=0;do forever;call delay(6000);if otherport='MIAMICONTROL.2' then;packet=getpkt('MIAMICONTROL.1');else;packet=getpkt('MIAMICONTROL.2');say packet;say cmd;if packet ~=NULL() then;do;cmd=getarg(packet);call reply(packet,0);call deletecheckpoint;call cleanup;end;address MIAMI.1;ISONLINE;if RC=1 then;do;options results;GETCONNECTTIME;contime=result;if OPEN(cpfile,'S:mccheckpoint.tmp','w') then;do;writeln(cpfile,contime);call CLOSE(cpfile);end;end;else;call cleanup;end;deletecheckpoint:;call delay(50);deleted= delete('S:mccheckpoint.tmp');say deleted;if deleted=0 then;do;if retry<5 then;do;retry=retry+1;call deletecheckpoint;end;if exists('Ram:mccheckpoint.tmp') then;call rtezrequest("Unable to delete checkpoint file!"||NL||"Upon it's next execution Miami Control will detect it,"||NL||"It is suggested that you tell it not to recover it next time you run it.","I Will","Error!","rtez_flags = ezreqf_centertext");call cleanup;end;call cleanup;cleanup:;if otherport='MIAMICONTROL.2' then;call CLOSEPORT('MIAMICONTROL.1');else;if otherport='MIAMICONTROL.1' then;call CLOSEPORT('MIAMICONTROL.2');exit